#pragma once

#include "cocos2d.h"
#include "ui/UIWidget.h"
#include "logic/LogicCache.h"
#include "SceneManager.h"
#include "LayerManager.h"
#include "logic/LogicData.h"
#include "CocosUiHelper.h"
#include "CommonUiManager.h"
#include "UiConfig.h"

class CSceneBase : public cocos2d::Scene
{
protected:
	typedef std::function<void(const std::string& err)> FuncReportError_t;
public:
	CSceneBase(void);
	virtual ~CSceneBase(void);

	bool init() override { return cocos2d::Scene::init(); }
	void SetReportErrFunc(FuncReportError_t func) { m_ReportErrFunc = func; }

	void ReportError(uint32_t err);
	void ReplaceScene(CSceneManager::ChildIndex index);
private:
	void onReportError(const std::string& err);
	void onReplaceScene(CSceneManager::ChildIndex index);
protected:
	cocos2d::Director*			m_Director;
	CSceneManager*				m_SceneManager;
	CLayerManager*				m_LayerManager;
	CLogicCache*				m_LogicCache;
	CLogicData*					m_LogicData;
	CCommonUiManager*			m_UiManager;
	CUiConfig*					m_UiConfig;
private:
	FuncReportError_t			m_ReportErrFunc;
};

